﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SME.Food.Surperise.BLL;
using SME.Food.Surperise.Model;

namespace SME.Food.Tricon.Web.AdminJS.MenusManage
{
    public partial class AddBatchFood : System.Web.UI.Page
    {
        private Bas_Dishes_BLL bll = new Bas_Dishes_BLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            string batchPrimaryKeyIds = Request.Form["ids"];
            string[] primaryKeyIds = null;
            //string[] stockNums = null;
            if (batchPrimaryKeyIds.Length > 0)
            {
                primaryKeyIds = batchPrimaryKeyIds.Split(',');
            }

            string addFoodIds = string.Empty;

            if (primaryKeyIds == null && primaryKeyIds.Length <= 0) return;

            StringBuilder sb = new StringBuilder();

            if (primaryKeyIds != null && primaryKeyIds.Length > 0)
            {
                for (int i = 0; i < primaryKeyIds.Length; i++)
                {
                    if (string.IsNullOrWhiteSpace(primaryKeyIds[i])) continue;
                    Bas_Dishes_Model modJxcEnterFood = bll.GetModel(primaryKeyIds[i]);
                    sb.Append("<tr>");
                    sb.Append("<td  >");
                    sb.AppendFormat("<input hidty='foodId' type='hidden' name='line[{0}].DishesNo' value='{1}'>",
                                    modJxcEnterFood.Dishes_No, modJxcEnterFood.Dishes_No);
                    //拼接本次主键的id字符串，其实就是ids，记录就是根据ids进行筛选出来的
                    addFoodIds += modJxcEnterFood.Dishes_No + ",";
                    sb.AppendFormat(
                        "<input type='text' style='float:left' readonly='readonly' size='16' name='lookup[{0}].DishesNo' value='{1}' lookuppk='id' size='12' class='required textInput readonly valid'>",
                        modJxcEnterFood.Dishes_No, modJxcEnterFood.Dishes_No);
                    sb.Append("</td>");

                    sb.Append("<td   >");
                    sb.AppendFormat(
                        "<input type='text' readonly='readonly' name='lookup[{0}].DishesName' size='20' value='{1}' size='12' class='required textInput readonly'>",
                        modJxcEnterFood.Dishes_No, modJxcEnterFood.Dishes_Name);
                    sb.Append("</td>");
                    sb.Append("<td >");
                    sb.AppendFormat(
                        "<input type='text' readonly='readonly' name='lookup[{0}].DishesPrice' value='{1}' size='12' class='required textInput readonly'>",
                        modJxcEnterFood.Dishes_No, modJxcEnterFood.Dishes_Price);
                    sb.Append("</td>");
                    sb.Append("<td >");
                    sb.AppendFormat(
                        "<input type='text'  name='lookup[{0}].Num' value='1' size='12' class='required textInput'>", modJxcEnterFood.Dishes_No);
                    sb.Append("</td>");
                  sb.Append("<td align='center'>");
                    sb.AppendFormat("<a href='javascript:void(0)' class=\"btnDel\"' rId='{0}' rIdType='0'></a>",
                                    modJxcEnterFood.Dishes_No);
                    sb.Append("</td>");

                    sb.AppendFormat("</tr>");
                }
                //返回数据到modify进行业务操作，sb为拼接控件，addFoodIds为已选的主键id字符串
                Response.Write(sb + "|" + addFoodIds);
            }

        }
    }
}